package com.demo.date;

import com.demo.date.entity.DateDto;
import org.apache.commons.lang3.tuple.Pair;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author : YU.TAN
 * @date : 2021/11/5 16:12
 */
public class TestA {
    public static void main(String[] args) throws ParseException {
        String dateA = "2015-11-10 17:10:03";
        String dateB = "2021-11-10 17:10:03";

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:SS");
        Date parseA = dateFormat.parse(dateA);
        Date parseB = dateFormat.parse(dateB);
        DateDto dateDto = new DateDto(parseA, parseB);

        while (dateDto.hasNext()) {
            Pair<Date, Date> next = dateDto.next();
            System.out.println(dateFormat.format(next.getKey()) + "---" + dateFormat.format(next.getValue()));
        }
    }
}
